农夫约翰的奶酪块

题目 农夫约翰的奶酪块

043c0790166badf37cee44b54ff65075_720-9687edf9

思路分析

50b446ecbf8a57e8fd668fddd59efda3_720-cab130c4

代码实现

#include<bits/stdc++.h
using namespace std;
#define endl '\n'

const int N=1010;
int n,Q;
int X[N][N],Y[N][N],Z[N][N];

int main()
{
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin>>n>>Q;
    int res=0;
    while(Q--){
        int x,y,z;
        cin>>x>>y>>z;
        X[x][y]++;
        Y[y][z]++;
        Z[x][z]++;

        if(X[x][y]>=n) res++;
        if(Y[y][z]>=n) res++;
        if(Z[x][z]>=n) res++;

        cout<<res<<endl;
    }
    return 0;
}

同类题型

视频讲解


⬅️ 健身 🏠 00-刷题理模型 ➡️ 划拳